﻿using System.Windows;
using System.Windows.Controls;

namespace CalciumTemplateApp.Controls
{
	/// <summary>
	/// This control displays the title of the bound viewmodel.
	/// </summary>
	public partial class TitleControl : UserControl
	{
		public TitleControl()
		{
			InitializeComponent();
		}

		#region PageTitleVisible Dependency Property

		public static DependencyProperty PageTitleVisibleProperty
			= DependencyProperty.Register("PageTitleVisible", typeof(bool), typeof(TitleControl), new PropertyMetadata(true, HandlePageTitleVisibleChanged));

		static void HandlePageTitleVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
		{
			var control = (TitleControl)d;
			control.textBlock_PageTitle.Visibility = (bool)e.NewValue ? Visibility.Visible : Visibility.Collapsed;
		}

		public bool PageTitleVisible
		{
			get
			{
				return (bool)GetValue(PageTitleVisibleProperty);
			}
			set
			{
				SetValue(PageTitleVisibleProperty, value);
			}
		}

		#endregion
	}
}
